package com.linwj.hello.spring.cloud.alibaba.provider.controller;

import com.sun.javafx.binding.StringFormatter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class NacosProviderController {
    @Value("${server.port}")
    private String port;

    @Autowired
    private ConfigurableApplicationContext applicationContext;

    @GetMapping(value = "/echo/{message}")
    public String echo(@PathVariable String message) {
        return String.format("hello nacos %s, i port is %s", message, port);
    }

    @GetMapping(value = "/hi")
    public void sayHi(@RequestParam String msg) {
        log.error("hi "+msg+"=========================");
//        return "Hello "+msg + applicationContext.getEnvironment().getProperty("user.name");
    }
}

